import { EntitySchema } from '@mikro-orm/core';

export class LeUser {
  id!: string;
  nickname!: string;
  mobile?: string;
  realname?: string;
  avatar!: string;
  gender: boolean = false;
  source!: string;
  status: boolean = false;
  parentId?: string;
  bindTime?: string;
  AppID!: string;
  isDeleted: boolean = false;
  createdTime?: string;
  updatedTime?: string;
  deletedTime?: string;
  birthday?: string;
  area?: string;
  wechat?: string;
  isEdit: boolean = true;
}

export const LeUserSchema = new EntitySchema({
  class: LeUser,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    nickname: { type: 'string', length: 50 },
    mobile: { type: 'string', columnType: 'bigint', nullable: true },
    realname: { type: 'string', length: 50, nullable: true },
    avatar: { type: 'string', length: 255 },
    gender: { type: 'boolean', default: false },
    source: { type: 'string', length: 50 },
    status: { type: 'boolean', default: false },
    parentId: { type: 'string', columnType: 'bigint', nullable: true, defaultRaw: `0` },
    bindTime: { type: 'string', columnType: 'bigint', nullable: true },
    AppID: { type: 'string', fieldName: 'AppID', length: 32, index: '应用id' },
    isDeleted: { type: 'boolean', default: false },
    createdTime: { type: 'string', columnType: 'bigint', nullable: true },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    birthday: { type: 'string', length: 50, nullable: true },
    area: { type: 'string', length: 255, nullable: true },
    wechat: { type: 'string', length: 50, nullable: true },
    isEdit: { type: 'boolean', default: true },
  },
});
